package com.shd.edanpei.ui.adapter;

import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by mc on 2018/9/20.
 * yang-wen-wen
 */

public class TabViewPagerAdapter extends PagerAdapter {

    private String[] tabs;
    private List<View> tabList;

    public TabViewPagerAdapter(String[] tabs, List<View> tabList) {
        this.tabs = tabs;
        this.tabList = tabList;
    }

    @Override
    public int getCount() {
        return tabs.length;
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        container.addView(tabList.get(position));
        return tabList.get(position);
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View) object);
    }
}